<%-- 
    Document   : addcontact
    Created on : 24 déc. 2013, 13:46:40
    Author     : root
--%>

<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Map.Entry"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.Map"%>
<% String error="";
String name="";
String mail="";
String sorry="";
HttpSession thisSession = (HttpSession) request.getAttribute("thisSession");
   String msgFile = "";
    Map<String,String> waitingFile=(HashMap<String,String>) request.getAttribute("waitingFile");
    if(waitingFile.size()>0){
        msgFile = msgFile + "("+waitingFile.size()+")";
        
    }
    String demande="";
   ArrayList<String> demandeContact = (ArrayList<String>) thisSession.getAttribute("demandeContact");
   if(demandeContact.size()!=0){
       boolean accept = true;
       int notif = demandeContact.size();
       if(notif!=0){
           demande = " (" + notif+")";
       }
   }
Map<String,String> e=(Map<String,String>) request.getAttribute("erreur");
Map<String,String> results=(Map<String,String>) request.getAttribute("results");
if(e.containsKey("idError")){
error=e.get("idError");
}
if(e.containsKey("idSorry")){
sorry=e.get("idSorry");
}
ArrayList<String> newMessage = (ArrayList<String>) thisSession.getAttribute("newMessage");
String newMsg = "";
if(newMessage.size()!=0){
    newMsg= newMsg+" ("+newMessage.size()+")";
}
%>
<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/AddContact.css"/>
		<title>MISS AddContact</title>
	</head>
	<body>
            <header>
            <a href="RedirectConnected"><img src="Pictures/logo.png" class="logo" style="float: outside;"></a>
            <div class="zone">
                <div class="zone-right"></div>
                <div class="zone-left"></div>
                <div class="zone-bg">
                    <ul>
                        <li><a href="RedirectConnected"><span>Home <%= newMsg%></span></a></li>
                        <li class="current"><a href="NewContact.html"><span>Contact <%= demande%></span></a></li>
                        <li><a href="profile.html"><span>Profile</span></a></li>
                        <li><a href="File.html"><span>File <%= msgFile%></span></a></li>
                        <li><a href="Administrator.html"><span>Administration</span></a></li>
                        <li><a href="logout.html"><span>Logout</span></a></li>
                    </ul>
                </div>
            </div>
        </header>
		<div class="general">
		<h3>Add a contact</h3>
			<div class="search">
				<div id="search">
                                    <form method="post" action="AddContact">
                                        <label for="idSearch">search contact</label><input type="text" name="research" id="idSearch"><em><%=error%></em><br>
					By
					<select name="type" id="idSearch">
					 	<option value="login">Login</option>
					 	<option value="name">Name</option>
					 	<option value="mail">Mail</option>
					</select>
                                        <input type="submit" value="search">
                                    </form>
				</div>
			</div>
			<div class="results">
			<h5>Results</h5>
                        number of matches : <em><%= results.size() %> </em><em><%= sorry %></em>
                        
                            <% for(Entry<String, String> entry : results.entrySet()) {
                                    name = entry.getKey();
                                    mail = entry.getValue();
                            %>
                            
                                <div class="matches">
                                        <div id="name">Name : <%= name%></div> 
					<div id="mail">Mail : <%= mail%></div>
                                        <form method="post" action="Add">
                                            <input type="hidden" name="name" value="<%= name%>">
                                            <input type="image" src="Pictures/add.jpeg" onclick="submit">
                                        </form>
                                        
                                </div><br>	
                            
                            <%    }
                            %>
                            
                        
			</div>
		</div>
	</body>
</html>
